<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>林序3PG模型可视化系统-编辑树种参数</title>
{#    <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.3/css/bootstrap.min.css" rel="stylesheet">#}
{#    <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-icons/1.11.1/font/bootstrap-icons.min.css" rel="stylesheet">#}
{#    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>#}
{#    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.3/js/bootstrap.bundle.min.js"></script>#}

    <link href="{{ url_for('static',filename='bootstrap/css/bootstrap.min.css') }}" rel="stylesheet">
    <link href="{{ url_for('static',filename='bootstrap/bootstrap-icons-1.11.1/bootstrap-icons.min.css') }}" rel="stylesheet">
    <script src="{{ url_for('static',filename='jquery/jquery-3.7.1.min.js') }}"></script>
    <script src="{{ url_for('static',filename='bootstrap/js/bootstrap.bundle.min.js') }}"></script>
    <style>
        :root {
            --primary-color: #2E7D32;
            --secondary-color: #81C784;
            --accent-color: #DCEDC8;
            --text-color: #212121;
            --light-text: #757575;
            --light-green: #E8F5E9;
            --dark-green: #1B5E20;
            --amber: #FFD54F;
            --brown: #795548;
            --leaf-green: #66BB6A;
        }

        body {
            background-color: #F8F9FA;
            background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M54.627 0l.83.828-1.415 1.415L51.8 0h2.827zM5.373 0l-.83.828L5.96 2.243 8.2 0H5.374zM48.97 0l3.657 3.657-1.414 1.414L46.143 0h2.828zM11.03 0L7.372 3.657 8.787 5.07 13.857 0H11.03zm32.284 0L49.8 6.485 48.384 7.9l-7.9-7.9h2.83zM16.686 0L10.2 6.485 11.616 7.9l7.9-7.9h-2.83zm20.97 0l9.315 9.314-1.414 1.414L34.828 0h2.83zM22.344 0L13.03 9.314l1.414 1.414L25.172 0h-2.83zM32 0l12.142 12.142-1.414 1.414L30 .828 17.272 13.556l-1.414-1.414L28 0h4zM.284 0l28 28-1.414 1.414L0 2.544V0h.284zM0 5.373l25.456 25.455-1.414 1.415L0 8.2V5.374zm0 5.656l22.627 22.627-1.414 1.414L0 13.86v-2.83zm0 5.656l19.8 19.8-1.415 1.413L0 19.514v-2.83zm0 5.657l16.97 16.97-1.414 1.415L0 25.172v-2.83zM0 28l14.142 14.142-1.414 1.414L0 30.828V28zm0 5.657L11.314 44.97 9.9 46.386l-9.9-9.9v-2.828zm0 5.657L8.485 47.8 7.07 49.212 0 42.143v-2.83zm0 5.657l5.657 5.657-1.414 1.415L0 47.8v-2.83zm0 5.657l2.828 2.83-1.414 1.413L0 53.456v-2.83zM54.627 60L30 35.373 5.373 60H8.2L30 38.2 51.8 60h2.827zm-5.656 0L30 41.03 11.03 60h2.828L30 43.858 46.142 60h2.83zm-5.656 0L30 46.686 16.686 60h2.83L30 49.515 40.485 60h2.83zm-5.657 0L30 52.343 22.344 60h2.83L30 55.172 34.828 60h2.83zM32 60l-2-2-2 2h4zM59.716 0l-28 28 1.414 1.414L60 2.544V0h-.284zM60 5.373L34.544 30.828l1.414 1.415L60 8.2V5.374zm0 5.656L37.373 33.656l1.414 1.414L60 13.86v-2.83zm0 5.656l-19.8 19.8 1.415 1.413L60 19.514v-2.83zm0 5.657l-16.97 16.97 1.414 1.415L60 25.172v-2.83zM60 28L45.858 42.142l1.414 1.414L60 30.828V28zm0 5.657L48.686 44.97l1.415 1.415 9.9-9.9v-2.828zm0 5.657L51.515 47.8l1.414 1.414L60 42.143v-2.83zm0 5.657l-5.657 5.657 1.414 1.415L60 47.8v-2.83zm0 5.657l-2.828 2.83 1.414 1.413L60 53.456v-2.83zM39.9 16.385l1.414-1.414L30 3.658 18.686 14.97l1.415 1.415 9.9-9.9 9.9 9.9zm-2.83 2.828l1.415-1.414L30 9.313 21.515 17.8l1.414 1.413L30 11.8l7.07 7.414v-.002zm-2.827 2.83l1.414-1.416L30 14.97l-5.657 5.657 1.414 1.415L30 17.8l4.243 4.242zm-2.83 2.827l1.415-1.414L30 20.626l-2.828 2.83 1.414 1.414L30 23.456l1.414 1.414zM56.87 59.414L58.284 58 30 29.716 1.716 58l1.414 1.414L30 32.544l26.87 26.87z' fill='%2381c784' fill-opacity='0.07' fill-rule='evenodd'/%3E%3C/svg%3E");
            color: var(--text-color);
            padding: 2rem;
            min-height: 100vh;
        }

        .page-header {
            margin-bottom: 2.5rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding-bottom: 1.2rem;
            border-bottom: 1px solid rgba(0, 0, 0, 0.07);
        }

        .page-title {
            color: var(--primary-color);
            font-weight: 700;
            font-size: 2rem;
            margin-bottom: 0;
            position: relative;
            padding-left: 2.2rem;
        }

        .page-title::before {
            content: "";
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 1.8rem;
            height: 1.8rem;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24'%3E%3Cpath fill='none' d='M0 0h24v24H0z'/%3E%3Cpath d='M12.9 6.858l4.242 4.243L7.242 21H3v-4.243l9.9-9.9zm1.414-1.414l2.121-2.122a1 1 0 0 1 1.414 0l2.829 2.829a1 1 0 0 1 0 1.414l-2.122 2.121-4.242-4.242z' fill='%232E7D32'/%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-size: contain;
        }

        .parameter-section {
            background-color: white;
            border-radius: 12px;
            box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
            overflow: hidden;
            margin-bottom: 2rem;
            position: relative;
            scroll-margin-top: 80px;
        }

        .parameter-section::before {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 6px;
            background: linear-gradient(90deg, var(--leaf-green), var(--secondary-color));
        }

        .parameter-header {
            padding: 1.5rem;
            border-bottom: 1px solid rgba(0, 0, 0, 0.05);
            cursor: pointer;
            position: relative;
        }

        .parameter-header::after {
            content: "\F282";
            font-family: "bootstrap-icons";
            position: absolute;
            right: 1.5rem;
            top: 50%;
            transform: translateY(-50%);
            transition: transform 0.3s ease;
            color: var(--secondary-color);
        }

        .parameter-header.collapsed::after {
            transform: translateY(-50%) rotate(-90deg);
        }

        .parameter-title {
            font-weight: 600;
            color: var(--primary-color);
            margin-bottom: 0;
            font-size: 1.25rem;
            display: flex;
            align-items: center;
        }

        .parameter-title i {
            margin-right: 0.5rem;
            color: var(--leaf-green);
            font-size: 1.35rem;
        }

        .parameter-subtitle {
            color: var(--light-text);
            font-size: 0.9rem;
            margin-top: 0.5rem;
        }

        .parameter-content {
            padding: 1.5rem;
        }

        .parameter-content.collapsed {
            display: none;
        }

        .table-responsive {
            overflow-x: auto;
        }

        .parameter-table {
            width: 100%;
            border-collapse: separate;
            border-spacing: 0;
            font-family: 'Consolas', 'Menlo', 'Monaco', 'Courier New', monospace;
        }

        .parameter-table th {
            background-color: var(--light-green);
            color: var(--dark-green);
            font-weight: 600;
            text-align: left;
            padding: 0.6rem 1rem;
            font-size: 0.9rem;
            border-bottom: 2px solid var(--secondary-color);
        }

        .parameter-table td {
            padding: 0.35rem 1rem;
            border-bottom: 1px solid rgba(0, 0, 0, 0.05);
            vertical-align: middle;
            line-height: 1.2;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .parameter-table tr:last-child td {
            border-bottom: none;
        }

        .parameter-table tr:hover {
            background-color: rgba(0, 0, 0, 0.02);
        }

        .parameter-table tr:not(.category-header):not(.subcategory-header) {
            height: 34px;
        }

        .parameter-table th:nth-child(1),
        .parameter-table td:nth-child(1) {
            width: 55%;
            max-width: none;
            white-space: normal;
            word-wrap: break-word;
        }

        .parameter-table th:nth-child(2),
        .parameter-table td:nth-child(2) {
            width: 15%;
            white-space: nowrap;
        }

        .parameter-table th:nth-child(3),
        .parameter-table td:nth-child(3) {
            width: 10%;
            white-space: nowrap;
        }

        .parameter-table th:nth-child(4),
        .parameter-table td:nth-child(4) {
            width: 20%;
            vertical-align: middle;
            line-height: 1;
        }

        .parameter-table td:nth-child(2) {
            font-weight: 600;
            color: var(--primary-color);
        }

        .parameter-table td:nth-child(3) {
            color: var(--light-text);
            font-style: italic;
        }

        .parameter-table input[type="number"] {
            text-align: right;
            width: 100%;
            max-width: 120px;
            padding: 0.25rem 0.5rem;
            font-family: 'Consolas', 'Menlo', 'Monaco', 'Courier New', monospace;
            font-size: 0.85rem;
            height: 28px;
            min-height: unset;
        }

        .category-header {
            background-color: var(--light-green);
            color: var(--primary-color);
            font-weight: 600;
            padding: 0.6rem 1rem;
            border-bottom: 1px solid rgba(0, 0, 0, 0.05);
            cursor: pointer;
        }

        .subcategory-header {
            background-color: rgba(0, 0, 0, 0.02);
            color: var(--dark-green);
            font-weight: 500;
            padding: 0.6rem 1rem;
            border-bottom: 1px solid rgba(0, 0, 0, 0.05);
            cursor: pointer;
        }

        .category-header i.toggle-icon,
        .subcategory-header i.toggle-icon {
            margin-right: 0.5rem;
            transition: transform 0.2s ease;
        }

        .category-header.collapsed i.toggle-icon,
        .subcategory-header.collapsed i.toggle-icon {
            transform: rotate(-90deg);
        }

        .form-control {
            padding: 0.5rem 0.75rem;
            border-radius: 8px;
            border: 1px solid rgba(0, 0, 0, 0.1);
            transition: all 0.3s ease;
            min-height: unset;
            line-height: 1.2;
        }

        .form-control:focus {
            border-color: var(--secondary-color);
            box-shadow: 0 0 0 3px rgba(129, 199, 132, 0.25);
        }

        .btn-action {
            padding: 0.6rem 1.2rem;
            border-radius: 8px;
            font-weight: 500;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
            transition: all 0.3s ease;
        }

        .btn-primary {
            background-color: var(--primary-color);
            border-color: var(--primary-color);
        }

        .btn-primary:hover {
            background-color: var(--dark-green);
            border-color: var(--dark-green);
            box-shadow: 0 4px 12px rgba(46, 125, 50, 0.4);
            transform: translateY(-2px);
        }

        .btn-back {
            background-color: white;
            border-color: rgba(0, 0, 0, 0.1);
            color: var(--light-text);
        }

        .btn-back:hover {
            background-color: rgba(0, 0, 0, 0.05);
            color: var(--text-color);
            border-color: rgba(0, 0, 0, 0.2);
        }

        .species-name {
            font-weight: 600;
            color: var(--dark-green);
            background-color: var(--light-green);
            padding: 0.3rem 0.7rem;
            border-radius: 4px;
            margin-left: 0.5rem;
        }

        .actions-container {
            margin-top: 2rem;
            margin-bottom: 3rem;
            display: flex;
            justify-content: space-between;
        }

        .section-title {
            color: var(--primary-color);
            border-left: 4px solid var(--secondary-color);
            padding-left: 0.8rem;
            margin: 1.5rem 0 1rem;
            font-weight: 600;
        }

        .row-hover {
            background-color: rgba(129, 199, 132, 0.1);
        }

        .modified-row {
            background-color: rgba(255, 213, 79, 0.15);
        }

        .modified-field {
            border-color: var(--amber);
            background-color: rgba(255, 213, 79, 0.1);
        }

        .back-to-top {
            position: fixed;
            bottom: 2rem;
            right: 2rem;
            width: 3rem;
            height: 3rem;
            border-radius: 50%;
            background-color: var(--primary-color);
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 2px 10px rgba(0,0,0,0.2);
            cursor: pointer;
            opacity: 0;
            transition: opacity 0.3s ease;
            z-index: 1000;
        }

        .back-to-top.visible {
            opacity: 1;
        }

        .back-to-top:hover {
            background-color: var(--dark-green);
            transform: translateY(-3px);
            box-shadow: 0 4px 15px rgba(0,0,0,0.3);
        }

        .quick-nav {
            position: sticky;
            top: 0;
            background-color: white;
            padding: 0.75rem 1rem;
            border-radius: 12px;
            box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
            margin-bottom: 1.5rem;
            z-index: 100;
            display: flex;
            overflow-x: auto;
            white-space: nowrap;
            scrollbar-width: thin;
        }

        .quick-nav::-webkit-scrollbar {
            height: 6px;
        }

        .quick-nav::-webkit-scrollbar-thumb {
            background: var(--secondary-color);
            border-radius: 10px;
        }

        .quick-nav-item {
            margin-right: 1rem;
            padding: 0.5rem 1rem;
            border-radius: 8px;
            background-color: var(--light-green);
            color: var(--dark-green);
            cursor: pointer;
            transition: all 0.2s ease;
            display: inline-flex;
            align-items: center;
        }

        .quick-nav-item:hover, .quick-nav-item.active {
            background-color: var(--primary-color);
            color: white;
        }

        .quick-nav-item i {
            margin-right: 0.5rem;
        }

        @media (max-width: 768px) {
            .parameter-table th,
            .parameter-table td {
                padding: 0.6rem 0.8rem;
            }

            .page-title {
                font-size: 1.6rem;
            }

            .species-name {
                display: block;
                margin: 0.5rem 0 0;
                width: fit-content;
            }

            .parameter-table td:nth-child(3) {
                display: none;
            }

            .actions-container {
                flex-direction: column;
                gap: 1rem;
            }

            .actions-container button {
                width: 100%;
            }
        }

        @media (min-width: 992px) {
            .sticky-header {
                position: sticky;
                top: 0;
                z-index: 10;
            }
        }
    </style>
</head>
<body>
    <div class="container-fluid p-0">
        <!-- 页面标题和返回按钮 -->
        <div class="page-header">
            <h1 class="page-title">编辑树种参数<span class="species-name">{{ species.speciesname }}</span></h1>
            <button type="button" class="btn btn-back" onclick="window.location.href='{{ url_for('func.myspecies') }}'">
                <i class="bi bi-arrow-left"></i> 返回树种列表
            </button>
        </div>

        <form id="editSpeciesForm" action="{{ url_for('func.editsubmitspecies', speciesId=species.id) }}" method="post">
            <!-- 快速导航栏 -->
            <div class="quick-nav">
                <div class="quick-nav-item" data-target="section-biomassTurnover">
                    <i class="bi bi-distribute-vertical"></i> 生物量分配与周转
                </div>
                <div class="quick-nav-item" data-target="section-nppConductance">
                    <i class="bi bi-graph-up-arrow"></i> NPP与导度修正
                </div>
                <div class="quick-nav-item" data-target="section-stemMortality">
                    <i class="bi bi-tree"></i> 茎干死亡率与自疏
                </div>
                <div class="quick-nav-item" data-target="section-canopyStructure">
                    <i class="bi bi-layers"></i> 冠层结构与过程
                </div>
                <div class="quick-nav-item" data-target="section-woodProperties">
                    <i class="bi bi-layout-wtf"></i> 木材与林分特性
                </div>
                <div class="quick-nav-item" data-target="section-conversionFactors">
                    <i class="bi bi-arrow-left-right"></i> 转换因子
                </div>
            </div>
            <!-- 生物量分配与周转参数部分 -->
            <div class="parameter-section" id="section-biomassTurnover">
                <div class="parameter-header">
                    <h2 class="parameter-title">
                        <i class="bi bi-distribute-vertical"></i> 生物量分配与周转
                    </h2>
                    <p class="parameter-subtitle">设置树木生物量分配和周转相关的参数</p>
                </div>
                <div class="parameter-content">
                    <div class="table-responsive">
                        <table class="parameter-table">
                            <thead>
                                <tr>
                                    <th width="45%">描述</th>
                                    <th width="15%">参数名</th>
                                    <th width="15%">单位</th>
                                    <th width="25%">值</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr class="subcategory-header">
                                    <td colspan="4"><i class="bi bi-chevron-down toggle-icon"></i>相对关系与分配</td>
                                </tr>
                                <tr>
                                    <td>Foliage:stem partitioning ratio @ D=2 cm</td>
                                    <td>pFS2</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="pFS2" class="form-control" value="{{ species.pFS2 }}"></td>
                                </tr>
                                <tr>
                                    <td>Foliage:stem partitioning ratio @ D=20 cm</td>
                                    <td>pFS20</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="pFS20" class="form-control" value="{{ species.pFS20 }}"></td>
                                </tr>
                                <tr>
                                    <td>Constant in the stem mass v. diam. relationship</td>
                                    <td>aS</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="aS" class="form-control" value="{{ species.aS }}"></td>
                                </tr>
                                <tr>
                                    <td>Power in the stem mass v. diam. relationship</td>
                                    <td>nS</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="nS" class="form-control" value="{{ species.nS }}"></td>
                                </tr>
                                <tr>
                                    <td>Maximum fraction of NPP to roots</td>
                                    <td>pRx</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="pRx" class="form-control" value="{{ species.pRx }}"></td>
                                </tr>
                                <tr>
                                    <td>Minimum fraction of NPP to roots</td>
                                    <td>pRn</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="pRn" class="form-control" value="{{ species.pRn }}"></td>
                                </tr>
                                <tr class="subcategory-header">
                                    <td colspan="4"><i class="bi bi-chevron-down toggle-icon"></i>落叶与根系周转</td>
                                </tr>
                                <tr>
                                    <td>Maximum litterfall rate</td>
                                    <td>gammaFx</td>
                                    <td>1/month</td>
                                    <td><input type="number" step="0.0001" required name="gammaFx" class="form-control" value="{{ species.gammaFx }}"></td>
                                </tr>
                                <tr>
                                    <td>Litterfall rate at t = 0</td>
                                    <td>gammaF0</td>
                                    <td>1/month</td>
                                    <td><input type="number" step="0.0001" required name="gammaF0" class="form-control" value="{{ species.gammaF0 }}"></td>
                                </tr>
                                <tr>
                                    <td>Age at which litterfall rate has median value</td>
                                    <td>tgammaF</td>
                                    <td>months</td>
                                    <td><input type="number" step="0.0001" required name="tgammaF" class="form-control" value="{{ species.tgammaF }}"></td>
                                </tr>
                                <tr>
                                    <td>Average monthly root turnover rate</td>
                                    <td>gammaR</td>
                                    <td>1/month</td>
                                    <td><input type="number" step="0.0001" required name="gammaR" class="form-control" value="{{ species.gammaR }}"></td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>

            <!-- NPP与导度修正参数部分 -->
            <div class="parameter-section" id="section-nppConductance">
                <div class="parameter-header">
                    <h2 class="parameter-title">
                        <i class="bi bi-graph-up-arrow"></i> NPP与导度修正
                    </h2>
                    <p class="parameter-subtitle">设置净初级生产力与导度修正相关的参数</p>
                </div>
                <div class="parameter-content">
                    <div class="table-responsive">
                        <table class="parameter-table">
                            <thead>
                                <tr>
                                    <th width="45%">描述</th>
                                    <th width="15%">参数名</th>
                                    <th width="15%">单位</th>
                                    <th width="25%">值</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr class="subcategory-header">
                                    <td colspan="4"><i class="bi bi-chevron-down toggle-icon"></i>温度修正 (fT)</td>
                                </tr>
                                <tr>
                                    <td>Minimum temperature for growth</td>
                                    <td>Tmin</td>
                                    <td>deg. C</td>
                                    <td><input type="number" step="0.0001" required name="Tmin" class="form-control" value="{{ species.Tmin }}"></td>
                                </tr>
                                <tr>
                                    <td>Optimum temperature for growth</td>
                                    <td>Topt</td>
                                    <td>deg. C</td>
                                    <td><input type="number" step="0.0001" required name="Topt" class="form-control" value="{{ species.Topt }}"></td>
                                </tr>
                                <tr>
                                    <td>Maximum temperature for growth</td>
                                    <td>Tmax</td>
                                    <td>deg. C</td>
                                    <td><input type="number" step="0.0001" required name="Tmax" class="form-control" value="{{ species.Tmax }}"></td>
                                </tr>
                                <tr class="subcategory-header">
                                    <td colspan="4"><i class="bi bi-chevron-down toggle-icon"></i>霜冻修正 (fFRost)</td>
                                </tr>
                                <tr>
                                    <td>Days production lost per frost day</td>
                                    <td>kF</td>
                                    <td>days</td>
                                    <td><input type="number" step="0.0001" required name="kF" class="form-control" value="{{ species.kF }}"></td>
                                </tr>
                                <tr class="subcategory-header">
                                    <td colspan="4"><i class="bi bi-chevron-down toggle-icon"></i>土壤水分修正 (fSW)</td>
                                </tr>
                                <tr>
                                    <td>Moisture ratio deficit for fθ = 0.5</td>
                                    <td>SWconst</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="SWconst" class="form-control" value="{{ species.SWconst }}"></td>
                                </tr>
                                <tr>
                                    <td>Power of moisture ratio deficit</td>
                                    <td>SWpower</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="SWpower" class="form-control" value="{{ species.SWpower }}"></td>
                                </tr>
                                <tr class="subcategory-header">
                                    <td colspan="4"><i class="bi bi-chevron-down toggle-icon"></i>大气CO2修正 (fCO2)</td>
                                </tr>
                                <tr>
                                    <td>Assimialtion enhancement factor at 700 ppm</td>
                                    <td>fCalpha700</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="fCalpha700" class="form-control" value="{{ species.fCalpha700 }}"></td>
                                </tr>
                                <tr>
                                    <td>Canopy conductance enhancement factor at 700 ppm</td>
                                    <td>fCg700</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="fCg700" class="form-control" value="{{ species.fCg700 }}"></td>
                                </tr>
                                <tr class="subcategory-header">
                                    <td colspan="4"><i class="bi bi-chevron-down toggle-icon"></i>养分效应</td>
                                </tr>
                                <tr>
                                    <td>Value of 'm' when FR = 0</td>
                                    <td>m0</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="m0" class="form-control" value="{{ species.m0 }}"></td>
                                </tr>
                                <tr>
                                    <td>Value of 'fNutr' when FR = 0</td>
                                    <td>fN0</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="fN0" class="form-control" value="{{ species.fN0 }}"></td>
                                </tr>
                                <tr>
                                    <td>Power of (1-FR) in 'fNutr'</td>
                                    <td>fNn</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="fNn" class="form-control" value="{{ species.fNn }}"></td>
                                </tr>
                                <tr class="subcategory-header">
                                    <td colspan="4"><i class="bi bi-chevron-down toggle-icon"></i>年龄修正 (fAge)</td>
                                </tr>
                                <tr>
                                    <td>Maximum stand age used in age modifier</td>
                                    <td>MaxAge</td>
                                    <td>years</td>
                                    <td><input type="number" step="0.0001" required name="MaxAge" class="form-control" value="{{ species.MaxAge }}"></td>
                                </tr>
                                <tr>
                                    <td>Power of relative age in function for fAge</td>
                                    <td>nAge</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="nAge" class="form-control" value="{{ species.nAge }}"></td>
                                </tr>
                                <tr>
                                    <td>Relative age to give fAge = 0.5</td>
                                    <td>rAge</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="rAge" class="form-control" value="{{ species.rAge }}"></td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>

            <!-- 茎干死亡率与自疏参数部分 -->
            <div class="parameter-section" id="section-stemMortality">
                <div class="parameter-header">
                    <h2 class="parameter-title">
                        <i class="bi bi-tree"></i> 茎干死亡率与自疏
                    </h2>
                    <p class="parameter-subtitle">设置茎干死亡率和自疏相关的参数</p>
                </div>
                <div class="parameter-content">
                    <div class="table-responsive">
                        <table class="parameter-table">
                            <thead>
                                <tr>
                                    <th width="45%">描述</th>
                                    <th width="15%">参数名</th>
                                    <th width="15%">单位</th>
                                    <th width="25%">值</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td>Mortality rate for large t</td>
                                    <td>gammaNx</td>
                                    <td>%/year</td>
                                    <td><input type="number" step="0.0001" required name="gammaNx" class="form-control" value="{{ species.gammaNx }}"></td>
                                </tr>
                                <tr>
                                    <td>Seedling mortality rate (t = 0)</td>
                                    <td>gammaN0</td>
                                    <td>%/year</td>
                                    <td><input type="number" step="0.0001" required name="gammaN0" class="form-control" value="{{ species.gammaN0 }}"></td>
                                </tr>
                                <tr>
                                    <td>Age at which mortality rate has median value</td>
                                    <td>tgammaN</td>
                                    <td>years</td>
                                    <td><input type="number" step="0.0001" required name="tgammaN" class="form-control" value="{{ species.tgammaN }}"></td>
                                </tr>
                                <tr>
                                    <td>Shape of mortality response</td>
                                    <td>ngammaN</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="ngammaN" class="form-control" value="{{ species.ngammaN }}"></td>
                                </tr>
                                <tr>
                                    <td>Max. stem mass per tree @ 1000 trees/hectare</td>
                                    <td>wSx1000</td>
                                    <td>kg/tree</td>
                                    <td><input type="number" step="0.0001" required name="wSx1000" class="form-control" value="{{ species.wSx1000 }}"></td>
                                </tr>
                                <tr>
                                    <td>Power in self-thinning rule</td>
                                    <td>thinPower</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="thinPower" class="form-control" value="{{ species.thinPower }}"></td>
                                </tr>
                                <tr>
                                    <td>Fraction mean single-tree foliage biomass lost per dead tree</td>
                                    <td>mF</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="mF" class="form-control" value="{{ species.mF }}"></td>
                                </tr>
                                <tr>
                                    <td>Fraction mean single-tree root biomass lost per dead tree</td>
                                    <td>mR</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="mR" class="form-control" value="{{ species.mR }}"></td>
                                </tr>
                                <tr>
                                    <td>Fraction mean single-tree stem biomass lost per dead tree</td>
                                    <td>mS</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="mS" class="form-control" value="{{ species.mS }}"></td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>

            <!-- 冠层结构与过程参数部分 -->
            <div class="parameter-section" id="section-canopyStructure">
                <div class="parameter-header">
                    <h2 class="parameter-title">
                        <i class="bi bi-layers"></i> 冠层结构与过程
                    </h2>
                    <p class="parameter-subtitle">设置冠层结构和相关过程的参数</p>
                </div>
                <div class="parameter-content">
                    <div class="table-responsive">
                        <table class="parameter-table">
                            <thead>
                                <tr>
                                    <th width="45%">描述</th>
                                    <th width="15%">参数名</th>
                                    <th width="15%">单位</th>
                                    <th width="25%">值</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr class="subcategory-header">
                                    <td colspan="4"><i class="bi bi-chevron-down toggle-icon"></i>比叶面积</td>
                                </tr>
                                <tr>
                                    <td>Specific leaf area at age 0</td>
                                    <td>SLA0</td>
                                    <td>m²/kg</td>
                                    <td><input type="number" step="0.0001" required name="SLA0" class="form-control" value="{{ species.SLA0 }}"></td>
                                </tr>
                                <tr>
                                    <td>Specific leaf area for mature leaves</td>
                                    <td>SLA1</td>
                                    <td>m²/kg</td>
                                    <td><input type="number" step="0.0001" required name="SLA1" class="form-control" value="{{ species.SLA1 }}"></td>
                                </tr>
                                <tr>
                                    <td>Age at which specific leaf area = (SLA0+SLA1)/2</td>
                                    <td>tSLA</td>
                                    <td>years</td>
                                    <td><input type="number" step="0.0001" required name="tSLA" class="form-control" value="{{ species.tSLA }}"></td>
                                </tr>
                                <tr class="subcategory-header">
                                    <td colspan="4"><i class="bi bi-chevron-down toggle-icon"></i>光拦截</td>
                                </tr>
                                <tr>
                                    <td>Extinction coefficient for absorption of PAR by canopy</td>
                                    <td>k</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="k" class="form-control" value="{{ species.k }}"></td>
                                </tr>
                                <tr>
                                    <td>Age at canopy cover</td>
                                    <td>fullCanAge</td>
                                    <td>years</td>
                                    <td><input type="number" step="0.0001" required name="fullCanAge" class="form-control" value="{{ species.fullCanAge }}"></td>
                                </tr>
                                <tr>
                                    <td>Maximum proportion of rainfall evaporated from canopy</td>
                                    <td>MaxIntcptn</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="MaxIntcptn" class="form-control" value="{{ species.MaxIntcptn }}"></td>
                                </tr>
                                <tr>
                                    <td>LAI for maximum rainfall interception</td>
                                    <td>LAImaxIntcptn</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="LAImaxIntcptn" class="form-control" value="{{ species.LAImaxIntcptn }}"></td>
                                </tr>
                                <tr class="subcategory-header">
                                    <td colspan="4"><i class="bi bi-chevron-down toggle-icon"></i>生产与呼吸</td>
                                </tr>
                                <tr>
                                    <td>Canopy quantum efficiency</td>
                                    <td>alpha</td>
                                    <td>molC/molPAR</td>
                                    <td><input type="number" step="0.0001" required name="alpha" class="form-control" value="{{ species.alpha }}"></td>
                                </tr>
                                <tr>
                                    <td>Ratio NPP/GPP</td>
                                    <td>Y</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="Y" class="form-control" value="{{ species.Y }}"></td>
                                </tr>
                                <tr class="subcategory-header">
                                    <td colspan="4"><i class="bi bi-chevron-down toggle-icon"></i>导度</td>
                                </tr>
                                <tr>
                                    <td>Minimum canopy conductance</td>
                                    <td>MinCond</td>
                                    <td>m/s</td>
                                    <td><input type="number" step="0.0001" required name="MinCond" class="form-control" value="{{ species.MinCond }}"></td>
                                </tr>
                                <tr>
                                    <td>Maximum canopy conductance</td>
                                    <td>MaxCond</td>
                                    <td>m/s</td>
                                    <td><input type="number" step="0.0001" required name="MaxCond" class="form-control" value="{{ species.MaxCond }}"></td>
                                </tr>
                                <tr>
                                    <td>LAI for maximum canopy conductance</td>
                                    <td>LAIgcx</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="LAIgcx" class="form-control" value="{{ species.LAIgcx }}"></td>
                                </tr>
                                <tr>
                                    <td>Defines stomatal response to VPD</td>
                                    <td>CoeffCond</td>
                                    <td>1/mBar</td>
                                    <td><input type="number" step="0.0001" required name="CoeffCond" class="form-control" value="{{ species.CoeffCond }}"></td>
                                </tr>
                                <tr>
                                    <td>Canopy boundary layer conductance</td>
                                    <td>BLcond</td>
                                    <td>m/s</td>
                                    <td><input type="number" step="0.0001" required name="BLcond" class="form-control" value="{{ species.BLcond }}"></td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>

            <!-- 木材与林分特性参数部分 -->
            <div class="parameter-section" id="section-woodProperties">
                <div class="parameter-header">
                    <h2 class="parameter-title">
                        <i class="bi bi-layout-wtf"></i> 木材与林分特性
                    </h2>
                    <p class="parameter-subtitle">设置木材与林分特性相关的参数</p>
                </div>
                <div class="parameter-content">
                    <div class="table-responsive">
                        <table class="parameter-table">
                            <thead>
                                <tr>
                                    <th width="45%">描述</th>
                                    <th width="15%">参数名</th>
                                    <th width="15%">单位</th>
                                    <th width="25%">值</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr class="subcategory-header">
                                    <td colspan="4"><i class="bi bi-chevron-down toggle-icon"></i>枝条和树皮比例 (fracBB)</td>
                                </tr>
                                <tr>
                                    <td>Branch and bark fraction at age 0</td>
                                    <td>fracBB0</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="fracBB0" class="form-control" value="{{ species.fracBB0 }}"></td>
                                </tr>
                                <tr>
                                    <td>Branch and bark fraction for mature stands</td>
                                    <td>fracBB1</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="fracBB1" class="form-control" value="{{ species.fracBB1 }}"></td>
                                </tr>
                                <tr>
                                    <td>Age at which fracBB = (fracBB0+fracBB1)/2</td>
                                    <td>tBB</td>
                                    <td>years</td>
                                    <td><input type="number" step="0.0001" required name="tBB" class="form-control" value="{{ species.tBB }}"></td>
                                </tr>
                                <tr class="subcategory-header">
                                    <td colspan="4"><i class="bi bi-chevron-down toggle-icon"></i>基本密度</td>
                                </tr>
                                <tr>
                                    <td>Minimum basic density - for young trees</td>
                                    <td>rhoMin</td>
                                    <td>t/m³</td>
                                    <td><input type="number" step="0.0001" required name="rhoMin" class="form-control" value="{{ species.rhoMin }}"></td>
                                </tr>
                                <tr>
                                    <td>Maximum basic density - for older trees</td>
                                    <td>rhoMax</td>
                                    <td>t/m³</td>
                                    <td><input type="number" step="0.0001" required name="rhoMax" class="form-control" value="{{ species.rhoMax }}"></td>
                                </tr>
                                <tr>
                                    <td>Age at which rho = (rhoMin+rhoMax)/2</td>
                                    <td>tRho</td>
                                    <td>years</td>
                                    <td><input type="number" step="0.0001" required name="tRho" class="form-control" value="{{ species.tRho }}"></td>
                                </tr>
                                <tr class="subcategory-header">
                                    <td colspan="4"><i class="bi bi-chevron-down toggle-icon"></i>茎干高度</td>
                                </tr>
                                <tr>
                                    <td>Constant in the stem height relationship</td>
                                    <td>aH</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="aH" class="form-control" value="{{ species.aH }}"></td>
                                </tr>
                                <tr>
                                    <td>Power of DBH in the stem height relationship</td>
                                    <td>nHB</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="nHB" class="form-control" value="{{ species.nHB }}"></td>
                                </tr>
                                <tr>
                                    <td>Power of stocking in the stem height relationship</td>
                                    <td>nHN</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="nHN" class="form-control" value="{{ species.nHN }}"></td>
                                </tr>
                                <tr class="subcategory-header">
                                    <td colspan="4"><i class="bi bi-chevron-down toggle-icon"></i>茎干体积</td>
                                </tr>
                                <tr>
                                    <td>Constant in the stem volume relationship</td>
                                    <td>aV</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="aV" class="form-control" value="{{ species.aV }}"></td>
                                </tr>
                                <tr>
                                    <td>Power of DBH in the stem volume relationship</td>
                                    <td>nVB</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="nVB" class="form-control" value="{{ species.nVB }}"></td>
                                </tr>
                                <tr>
                                    <td>Power of stocking in the stem volume relationship</td>
                                    <td>nVN</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="nVN" class="form-control" value="{{ species.nVN }}"></td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>

            <!-- 转换因子参数部分 -->
            <div class="parameter-section" id="section-conversionFactors">
                <div class="parameter-header">
                    <h2 class="parameter-title">
                        <i class="bi bi-arrow-left-right"></i> 转换因子
                    </h2>
                    <p class="parameter-subtitle">设置用于模型计算的转换因子参数</p>
                </div>
                <div class="parameter-content">
                    <div class="table-responsive">
                        <table class="parameter-table">
                            <thead>
                                <tr>
                                    <th width="45%">描述</th>
                                    <th width="15%">参数名</th>
                                    <th width="15%">单位</th>
                                    <th width="25%">值</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td>Intercept of net v. solar radiation relationship</td>
                                    <td>Qa</td>
                                    <td>W/m²</td>
                                    <td><input type="number" step="0.0001" required name="Qa" class="form-control" value="{{ species.Qa }}"></td>
                                </tr>
                                <tr>
                                    <td>Slope of net v. solar radiation relationship</td>
                                    <td>Qb</td>
                                    <td>-</td>
                                    <td><input type="number" step="0.0001" required name="Qb" class="form-control" value="{{ species.Qb }}"></td>
                                </tr>
                                <tr>
                                    <td>Molecular weight of dry matter</td>
                                    <td>gDM_mol</td>
                                    <td>gDM/mol</td>
                                    <td><input type="number" step="0.0001" required name="gDM_mol" class="form-control" value="{{ species.gDM_mol }}"></td>
                                </tr>
                                <tr>
                                    <td>Conversion of solar radiation to PAR</td>
                                    <td>molPAR_MJ</td>
                                    <td>mol/MJ</td>
                                    <td><input type="number" step="0.0001" required name="molPAR_MJ" class="form-control" value="{{ species.molPAR_MJ }}"></td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>

            <!-- 提交按钮区域 -->
            <div class="actions-container">
                <button type="button" class="btn btn-back" onclick="window.location.href='{{ url_for('func.myspecies') }}'">
                    <i class="bi bi-x-lg"></i> 取消修改
                </button>
                <button type="submit" class="btn btn-primary">
                    <i class="bi bi-check-lg"></i> 保存修改
                </button>
            </div>
        </form>
    </div>
    <div id="backToTop" class="back-to-top">
        <i class="bi bi-arrow-up"></i>
    </div>
    <script>
        $(document).ready(function() {
            // 初始化页面功能
            initPage();

            // 监听表单提交
            $('#editSpeciesForm').on('submit', function(e) {
                return validateForm(e);
            });

            // 初始化表单输入框的焦点和值变化事件
            initFormInputs();
        });

        // 初始化页面功能
        function initPage() {
            // 添加表格行悬停效果
            $('.parameter-table tbody tr').not('.category-header, .subcategory-header').hover(
                function() {
                    $(this).addClass('row-hover');
                },
                function() {
                    $(this).removeClass('row-hover');
                }
            );

            // 为所有类别标题添加折叠图标（如果没有的话）
            $('.category-header, .subcategory-header').each(function() {
                if(!$(this).find('.toggle-icon').length) {
                    $(this).find('td:first').prepend('<i class="bi bi-chevron-down toggle-icon"></i> ');
                }
            });

            // 为参数类别添加展开/折叠功能
            $('.category-header, .subcategory-header').click(function() {
                // 找到当前类别下的所有表格行，直到下一个同级或更高级的类别标题
                let selector = $(this).hasClass('category-header') ? '.category-header' : '.subcategory-header, .category-header';
                let rows = $(this).nextUntil(selector);

                // 切换显示/隐藏状态
                rows.not('.subcategory-header').toggleClass('d-none');
                $(this).toggleClass('collapsed');

                // 更改指示图标
                $(this).find('.toggle-icon').toggleClass('bi-chevron-down bi-chevron-right');
            });

            // 当窗口滚动时显示/隐藏返回顶部按钮
            $(window).scroll(function() {
                const scrollPosition = $(window).scrollTop();

                // 如果滚动超过300px，显示返回顶部按钮
                if (scrollPosition > 300) {
                    $('#backToTop').addClass('visible');
                } else {
                    $('#backToTop').removeClass('visible');
                }

                // 如果滚动超过一定距离，添加粘性表头
                if (scrollPosition > 200) {
                    $('.parameter-table thead').addClass('sticky-header');
                } else {
                    $('.parameter-table thead').removeClass('sticky-header');
                }
            });

            // 添加返回顶部按钮功能
            $('#backToTop').click(function() {
                $('html, body').animate({ scrollTop: 0 }, 'slow');
                return false;
            });

            // 添加参数卡片折叠/展开功能
            $('.parameter-header').click(function() {
                const content = $(this).siblings('.parameter-content');
                content.toggleClass('collapsed');
                $(this).toggleClass('collapsed');
            });

            // 快速导航功能
            $('.quick-nav-item').click(function() {
                const targetId = $(this).data('target');

                // 高亮当前选中的导航项
                $('.quick-nav-item').removeClass('active');
                $(this).addClass('active');

                // 滚动到目标位置
                $('html, body').animate({
                    scrollTop: $('#' + targetId).offset().top - 70
                }, 500);

                // 确保目标部分展开
                $('#' + targetId).find('.parameter-header.collapsed').click();
            });

            // 监听滚动，高亮当前所在部分的导航项
            $(window).scroll(function() {
                const scrollPosition = $(window).scrollTop() + 100;

                // 获取当前可见的部分
                $('.parameter-section').each(function() {
                    const top = $(this).offset().top;
                    const bottom = top + $(this).outerHeight();

                    if (scrollPosition >= top && scrollPosition <= bottom) {
                        const id = $(this).attr('id');
                        $('.quick-nav-item').removeClass('active');
                        $('.quick-nav-item[data-target="' + id + '"]').addClass('active');
                    }
                });
            });
        }

        // 初始化表单输入框
        function initFormInputs() {
            // 监听输入变化，高亮已修改的字段
            $('input[type="number"]').on('change', function() {
                $(this).addClass('modified-field');
                // 获取当前行以高亮显示
                $(this).closest('tr').addClass('modified-row');
            });

            // 添加按下回车键时自动聚焦到下一个输入框
            $('input[type="number"]').keydown(function(e) {
                if (e.which === 13) { // Enter key
                    e.preventDefault();

                    // 获取所有可见的数字输入框
                    const visibleInputs = $('input[type="number"]:visible');
                    const currentIndex = visibleInputs.index(this);

                    // 聚焦到下一个输入框
                    if (currentIndex < visibleInputs.length - 1) {
                        visibleInputs.eq(currentIndex + 1).focus();
                    }
                }
            });

            // 为输入框添加数值范围验证
            $('input[type="number"]').on('blur', function() {
                validateNumberInput($(this));
            });
        }

        // 验证数字输入
        function validateNumberInput(input) {
            const value = parseFloat(input.val());

            // 检查是否为有效数字
            if (isNaN(value)) {
                showInputError(input, '请输入有效的数字');
                return false;
            }

            // 根据参数名称执行特定验证
            const paramName = input.attr('name');

            // 示例：验证比例类参数必须在0-1之间
            if (['pFS2', 'pFS20', 'pRx', 'pRn', 'Y', 'fN0'].includes(paramName)) {
                if (value < 0 || value > 1) {
                    showInputError(input, '比例值必须在0-1之间');
                    return false;
                }
            }

            // 示例：验证温度参数的合理范围
            if (paramName === 'Topt') {
                const tMin = parseFloat($('input[name="Tmin"]').val());
                const tMax = parseFloat($('input[name="Tmax"]').val());

                if (value <= tMin || value >= tMax) {
                    showInputError(input, '最适温度必须在最低温度和最高温度之间');
                    return false;
                }
            }

            // 通过验证，清除错误提示
            clearInputError(input);
            return true;
        }

        // 显示输入错误提示
        function showInputError(input, message) {
            // 清除之前的错误提示
            clearInputError(input);

            // 添加错误状态和提示
            input.addClass('is-invalid');

            // 创建错误提示元素
            const errorFeedback = $('<div class="invalid-feedback"></div>').text(message);
            input.after(errorFeedback);
        }

        // 清除输入错误提示
        function clearInputError(input) {
            input.removeClass('is-invalid');
            input.next('.invalid-feedback').remove();
        }

        // 表单提交验证
        function validateForm(e) {
            let isValid = true;

            // 验证所有数字输入框
            $('input[type="number"]').each(function() {
                if (!validateNumberInput($(this))) {
                    isValid = false;
                }
            });

            // 验证特定参数组合的逻辑关系
            if (!validateParameterRelationships()) {
                isValid = false;
            }

            if (!isValid) {
                e.preventDefault();

                // 滚动到第一个错误输入
                const firstError = $('.is-invalid').first();
                if (firstError.length) {
                    $('html, body').animate({
                        scrollTop: firstError.offset().top - 100
                    }, 500);
                }

                // 显示错误提示
                showFormError('请修正表单中的错误后再提交');
                return false;
            }

            // 显示保存中状态
            showSavingStatus();
            return true;
        }

        // 验证参数之间的逻辑关系
        function validateParameterRelationships() {
            let isValid = true;

            // 验证温度参数关系：Tmin < Topt < Tmax
            const tMin = parseFloat($('input[name="Tmin"]').val());
            const tOpt = parseFloat($('input[name="Topt"]').val());
            const tMax = parseFloat($('input[name="Tmax"]').val());

            if (tMin >= tOpt || tOpt >= tMax) {
                showFormError('温度参数必须满足: 最低温度 < 最适温度 < 最高温度');
                isValid = false;
            }

            // 可以添加更多参数间的逻辑关系验证

            return isValid;
        }

        // 显示表单错误
        function showFormError(message) {
            // 移除之前的错误提示
            $('.form-error-alert').remove();

            // 创建错误提示
            const errorAlert = $(`
                <div class="alert alert-danger form-error-alert" role="alert">
                    <i class="bi bi-exclamation-triangle-fill me-2"></i>
                    ${message}
                </div>
            `);

            // 添加到页面顶部
            $('.page-header').after(errorAlert);

            // 滚动到错误提示
            $('html, body').animate({
                scrollTop: errorAlert.offset().top - 80
            }, 500);
        }

        // 显示保存中状态
        function showSavingStatus() {
            const submitBtn = $('button[type="submit"]');
            submitBtn.prop('disabled', true);

            // 保存原始文本
            const originalText = submitBtn.html();

            // 显示保存中状态
            submitBtn.html('<span class="spinner-border spinner-border-sm me-2" role="status" aria-hidden="true"></span>保存中...');

            // 5秒后恢复按钮状态（如果表单提交成功，页面会刷新）
            setTimeout(function() {
                submitBtn.html(originalText);
                submitBtn.prop('disabled', false);
            }, 5000);
        }
    </script>
</body>
</html>